package cn.wolfcode.shop.mapper;

import cn.wolfcode.shop.domain.SeckillGood;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by wolfcode-lanxw
 */
@Mapper
public interface SeckillGoodMapper {
    @Select("select * from t_seckill_goods")
    List<SeckillGood> query();
    @Select("select * from t_seckill_goods where id = #{goodId}")
    List<SeckillGood> selectByPirmaryKey(Long goodId);
    @Update("update t_seckill_goods set stock_count = stock_count-1 where id = #{goodId} and stock_count>0")
    int reduceStock(Long goodId);
    @Select("select stock_count from t_seckill_goods where id = #{goodId}")
    int getGoodStockById(Long goodId);
}
